import pymysql

class DB():
    def __init__(self):
        self.con = pymysql.connect(host='localhost',port=3306,user='root',password='123',charset='utf8',db='one',cursorclass=pymysql.cursors.DictCursor)
        self.cursor = self.con.cursor()

    def update(self,sql):
        self.cursor.execute(sql)
        self.con.commit()

    def find(self,sql):
        self.cursor.execute(sql)
        res= self.cursor.fetchone()  
        return res  
    
    def findall(self,sql):
        self.cursor.execute(sql)
        res=self.cursor.fetchall()
        return res

    def colse(self):
        self.cursor.close()
        self.con.close()

db1 = DB()
